package module4;

public class Member {
    //1. 属性: 姓名,年龄
    private int age;
    private String name;

    public Member() {
    }

    public Member(int age, String name) {
        //2. 如果年龄小于18龄大于150抛出年龄异常
        if (age > 150 || age < 18){
            throw new RuntimeException("年龄异常");
        }else{
            this.age = age;
        }
        //3. 如果姓名为null或者""抛出空异常
        if(name == null || "".equals(name)){
            throw new RuntimeException("空姓名异常");
        }else{
            this.name = name;
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
